package com.itqian.common.exception;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;

import java.util.List;

/**
 * @author shishuqian
 * date 2022/1/12
 * time 20:04
 **/
@Slf4j
public class Assert {


    public static void notNull(Object obj, ResponseEnum responseEnum){
        if(obj == null){
            log.info("数据为null");
            throw new EorderException(responseEnum.getMsg());
        }
    }

    public static void notBlank(String str,ResponseEnum responseEnum){
        if (StringUtils.isBlank(str)){
            log.info("字符串为空");
            throw new EorderException(responseEnum.getMsg());
        }
    }

    public static void equals(Object obj1, Object obj2, ResponseEnum responseEnum) {
        if (!obj1.equals(obj2)) {
            log.info("{}和{}不相等",obj1,obj2);
            throw new EorderException(responseEnum.getMsg());
        }
    }

    public static void isTrue(boolean expression, ResponseEnum responseEnum) {
        if (!expression) {
            log.info("验证失败");
            throw new EorderException(responseEnum.getMsg());
        }
    }


}
